var Stack = (function () {
  var _items = new WeakMap();
  return class Stack {
    constructor() {
      _items.set(this, []);
    }
    push(elem) {
      _items.get(this).push(elem);
    }
    pop() {
    return  _items.get(this).pop();
    }
    peek() {
      return _items.get(this)[_items.get(this).length - 1];
    }
    isEmpty() {
      return _items.get(this).length === 0;
    }
    clear() {
      _items.set(this, []);
    }
    size() {
      return _items.get(this).length;
    }
    toString() {
      return _items.get(this).toString();
    }
  };
})();
function binary(num,base) {
  let s = new Stack(),
    rem =-1,
    res = "",
    digits='0123456780abcdef'
  while (num > 0) {
    rem = num % base;
    s.push(rem);
    num = Math.floor(num / base);
  }
  while(!s.isEmpty()){
    res+=digits[s.pop()]
  }
  console.log(res);
}
binary(1000,16)